{% extends "base.html" %}

{% comment %}
<!--
Override blocks  prevent the css/js resources
from being loaded multiple times
-->
{% endcomment %}
{% block css_override %}
{% endblock %}
{% block javascript_override %}
{% endblock %}

{% block body %}
  <form id="{% block form_id %}{% endblock %}" method="POST" action="{% block form_url %}{% endblock %}">{% csrf_token %}
    {% block content %}
    {% endblock %}
	<div style="clear:both;"></div>
    <input type="submit" value="Submit" />
  </form>
{% endblock %}

{% block javascript_extend %}
<script>
// Submits the form via ajax, and updates the form content div
// with the returned response.
var form = $('{% block jquery_form_selector %}{% endblock %}')
$(form).submit(function() {
  $.ajax({
	type: form.attr('method'),
	url: form.attr('action'),
	data: form.serialize(),
	success: function(response) { $('{% block form_div %}{% endblock %}').html(response) }
  });
  return false;
});

// Attach the bootstrap datepicker widget to date fields.
$('.datepicker').datepicker({format: 'dd/mm/yyyy',
                             viewMode: 2});
</script>
{% endblock %}